From fd5e36604a4def2575e4888d679ed897ea2505a4 Mon Sep 17 00:00:00 2001 From: "robertlipe@gmail.com" Date: Wed, 1 Jan 2014 04:22:06 +0000 Subject: [PATCH] More QString tweaks. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4692 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/alan.cc | 14 ++++++++++---- gpsbabel/bushnell.cc | 2 +- gpsbabel/dmtlog.cc | 23 ++--------------------- 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/gpsbabel/alan.cc b/gpsbabel/alan.cc index 3ae0dcb55..e4b10901d 100644 --- a/gpsbabel/alan.cc +++ b/gpsbabel/alan.cc @@ -513,7 +513,9 @@ static waypoint* get_wpt(struct wprdata* wprdata, unsigned n) WP->longitude = pt2deg(wpt->pt.x); WP->SetCreationTime(unpack_time(wpt->date, wpt->time)); for (j=WPT_NAME_LEN-1; j >= 0 && wpt->name[j] == ' '; j--) {}; - WP->shortname = xstrndup(wpt->name,j+1); + char *s = xstrndup(wpt->name,j+1); + WP->shortname = s; + xfree(s); for (j=WPT_COMMENT_LEN-1; j >= 0 && wpt->comment[j] == ' '; j--) {}; if (j >= 0) { char *s = xstrndup(wpt->comment, j+1); @@ -565,12 +567,16 @@ static void wpr_read(void) RT = route_head_alloc(); RT->rte_num = i; for (j=RTE_NAME_LEN-1; j >= 0 && rte->name[j] == ' '; j--) {}; - RT->rte_name = xstrndup(rte->name,j+1); + char *s = xstrndup(rte->name,j+1); + RT->rte_name = s; + xfree(s); for (j=RTE_COMMENT_LEN-1; j >= 0 && rte->comment[j] == ' '; j--) {}; if (j >= 0) { - RT->rte_desc = xstrndup(rte->comment,j+1); + char *s = xstrndup(rte->comment,j+1); + RT->rte_desc = s; + xfree(s); } else { - RT->rte_desc = xstrdup(""); + RT->rte_desc = ""; } route_add_head(RT); diff --git a/gpsbabel/bushnell.cc b/gpsbabel/bushnell.cc index 479e1b48d..5c712ab9d 100644 --- a/gpsbabel/bushnell.cc +++ b/gpsbabel/bushnell.cc @@ -219,7 +219,7 @@ bushnell_read(void) // Apparently this is always zero terminated, though it's never been // observed to be longer than 19 bytes + a null terminator. - wpt_tmp->shortname = xstrdup(gbfgetstr(file_in)); + wpt_tmp->shortname = gbfgetstr(file_in); waypt_add(wpt_tmp); } diff --git a/gpsbabel/dmtlog.cc b/gpsbabel/dmtlog.cc index bcb7408e7..8a153dd9b 100644 --- a/gpsbabel/dmtlog.cc +++ b/gpsbabel/dmtlog.cc @@ -283,13 +283,7 @@ tlog3b_xgcb_tpten(xg_string args, const QXmlStreamAttributes* unused) static void tlog3b_xgcb_wptid(xg_string args, const QXmlStreamAttributes* unused) { -#if NEW_STRINGS xmlwpt->shortname = args; -#else - if (*args) { - xmlwpt->shortname = xstrdup(args); - } -#endif } @@ -319,33 +313,20 @@ tlog3b_xgcb_wptgr(xg_string args, const QXmlStreamAttributes* unused) static void tlog3b_xgcb_wptno(xg_string args, const QXmlStreamAttributes* unused) { -#if NEW_STRINGS xmlNorthing = args.toDouble(); -#else - xmlNorthing = atof(args); -#endif } - static void tlog3b_xgcb_wptea(xg_string args, const QXmlStreamAttributes* unused) { -#if NEW_STRINGS xmlEasting = args.toDouble(); -#else - xmlEasting = atof(args); -#endif } static void tlog3b_xgcb_wptal(xg_string args, const QXmlStreamAttributes* unused) { -#if NEW_STRINGS xmlAltitude = args.toDouble(); -#else - xmlAltitude = atof(args); -#endif } @@ -595,10 +576,10 @@ read_CTrackFile(const int version) if (name && *name) { switch (i) { case 0: - wpt->description = xstrdup(name); + wpt->description = name; break; case 1: - wpt->shortname = xstrdup(name); + wpt->shortname = name; break; } } -- 2.30.2